package dxo;

import java.util.ArrayList;
import java.util.List;

import dto.Layer;
import dto.Sample;

public class SampleTo {
	public static List<Layer> toLayer(List<Sample> samples) {
		int l = samples.get(0).getLayers().length;
		int n = samples.size();
		
		int [][] layers = new int[l][n];
		
		int s = 0;
		for(Sample sample : samples) {
			int [] ls = sample.getLayers();
			for(int i = 0; i < ls.length; i++) {
				layers[i][s] = ls[i];
			}
			s ++;
		}
		
		List<Layer> layerList = new ArrayList<Layer>(l);
		for(int i = 0; i < l; i++) {
			Layer layer = new Layer();
			layer.setNumber(i);
			layer.setPrediction(layers[i]);
			layerList.add(layer);
		}
		
		return layerList;
	}
	
	public static List<Integer> toLabel(List<Sample> samples) {
		List<Integer> result = new ArrayList<Integer>(samples.size());
		for(Sample sample : samples) {
			result.add(sample.getLabel());
		}
		return result;
	}

}
